package com.cloud.flowable.controller;

import com.cloud.common.domain.Result;
import com.cloud.flowable.service.IWfInstanceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "流程实例管理")
@RestController
@RequestMapping("/flowable/instance")
public class WfInstanceController {

    @Autowired
    private IWfInstanceService instanceService;

    @Operation(summary = "激活或挂起流程实例")
    @GetMapping(value = "/updateState")
    public Result updateState(@RequestParam Integer state, @RequestParam String instanceId) {
        instanceService.updateState(state, instanceId);
        return Result.success("修改成功");
    }

    @Operation(summary = "删除流程实例")
    @PostMapping(value = "/delete")
    public Result delete(@RequestParam String instanceId, String deleteReason) {
        instanceService.delete(instanceId, deleteReason);
        return Result.success("删除成功");
    }

    @Operation(summary = "查询流程实例详情信息")
    @GetMapping("/detail")
    public Result detail(String procInsId, String deployId) {
        return Result.success("查询成功", instanceService.queryDetailProcess(procInsId, deployId));
    }

}
